import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 * 
 */

/**
 * @author MegaTool
 *
 */
public class GameFrame extends JFrame implements KeyListener{

	private GamePanel gamePanel; //The main gameboard
	Point playersCurrentPoint; // The players current position on whatever map they are on
	
	/**
	 * 
	 * @param title This is inherited and is the title of the window
	 */
	public GameFrame(String title){
		super(title);
		playersCurrentPoint = new Point();
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
					
		int scale = 3; //SCale of the game
		gamePanel = new GamePanel("Passenger_Bay_3.map", scale);
				
		add(gamePanel);
				
		addKeyListener(this);
		setSize(720,480);
		setVisible(true);
	}

	
	@Override
	public void keyPressed(KeyEvent arg0) {
		
		ActionTrigger trigger  = new ActionTrigger();
		switch(arg0.getKeyCode() ) {
		case KeyEvent.VK_UP:
			playersCurrentPoint = gamePanel.moveDirection(GamePanel.NORTH);
			trigger.x = playersCurrentPoint.x;
			trigger.y = playersCurrentPoint.y;
			trigger.setFacing(GamePanel.NORTH);
			break;
		case KeyEvent.VK_DOWN:
			playersCurrentPoint = gamePanel.moveDirection(GamePanel.SOUTH);
			trigger.x = playersCurrentPoint.x;
			trigger.y = playersCurrentPoint.y;
			trigger.setFacing(GamePanel.SOUTH);
			break;
		case KeyEvent.VK_RIGHT:
			playersCurrentPoint = gamePanel.moveDirection(GamePanel.EAST);
			trigger.x = playersCurrentPoint.x;
			trigger.y = playersCurrentPoint.y;
			trigger.setFacing(GamePanel.EAST);
			break;
		case KeyEvent.VK_LEFT:
			playersCurrentPoint = gamePanel.moveDirection(GamePanel.WEST);
			trigger.x = playersCurrentPoint.x;
			trigger.y = playersCurrentPoint.y;
			trigger.setFacing(GamePanel.WEST);
			break;
		}
		//actionList.setAction(trigger);
		
		
	}//end keyPressed()

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

}
